package lab02.test37;

import lab02.test37.Student;

import java.util.Scanner;

public class StudentDemo {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println("输入几个学生的信息：");

        Student[] student = new Student[scanner.nextInt()];
        //名字
        for (int i = 0; i < student.length; i++) {
            Scanner scanner1 = new Scanner(System.in);

            System.out.println("输入系别：");

            String temp = scanner1.nextLine();
            if ("研究生".equals(temp)) {

                System.out.println("输入名字：");

                student[i] = new Graduate(scanner1.nextLine());

                System.out.println("输入" + student[i].getName() + "的第几门课 及这门课的成绩：");

                student[i].setCoursesgrade(scanner.nextInt() - 1, scanner.nextInt());
                student[i].setCoursesgrade(scanner.nextInt() - 1, scanner.nextInt());
                student[i].setCoursesgrade(scanner.nextInt() - 1, scanner.nextInt());
                student[i].graderank();
            } else if ("本科生".equals(temp)) {

                System.out.println("输入名字：");

                student[i] = new Undergraduate(scanner1.nextLine());

                System.out.println("输入" + student[i].getName() + "的第几门课 及这门课的成绩：");

                student[i].setCoursesgrade(scanner.nextInt() - 1, scanner.nextInt());
                student[i].setCoursesgrade(scanner.nextInt() - 1, scanner.nextInt());
                student[i].setCoursesgrade(scanner.nextInt() - 1, scanner.nextInt());
                student[i].graderank();
            }
        }

        System.out.println("姓名" + "\t" + "类型" + "\t" + "成绩");

        for (int i = 0; i < student.length; i++) {
            System.out.println(student[i].getName() + "\t" + student[i].getDept() + "\t" + student[i].getGradeRank());
        }

    }
}
